package demo06

import scala.collection.mutable

/**
 * @author xiaoZhao
 * @date 2022/7/11
 * @describe 可变的Set
 */
object Test07_MutableSet {
  def main(args: Array[String]): Unit = {
    // 1.创建Set
    val set1 = mutable.Set(12,78,90,56,78,12,34,23)
    println(set1)

    /// 2.添加元素
    val set2 = set1 + 32
    println(set1)
    println(set2)

    set1 += 88
    println(set1)

    set1.add(30)
    println(set1)

    // 3.删除元素
    set1 -= 12
    println(set1)
    set1.remove(23)
    println(set1)

    // 4.合并两个集合
    val set3 = mutable.Set(75,90,56,39,54,51)

    val set4 = set1 ++ set3
    println(set4)

    set1 ++= set3
    println(set1)
  }
}
